/***************************************** 
 * Desc: 路径数据
 * @Author: GSan
 * @Email: 2087653648@qq.com
 * CreateDate: 2020-07-14 10:05:17
*****************************************/

using System.Collections.Generic;
using UnityEngine;

namespace Common.UGUI.Base.Data {

	public class UGUIBaseData : MonoBehaviour {

		#region 域

		[HideInInspector]
		public int ResolutionX = 1080;
		[HideInInspector]
		public int ResolutionY = 1920;

		public static readonly string BundlePath = "Base/";
		public static readonly string PrefabName = "UGUIBaseData.prefab";
        public static readonly Dictionary<string, string> UIName2BundleDict = new Dictionary<string, string>();

		public List<string> BaseCanvasList {
            get {
				return _baseCanvasList;
			}
        }

		public List<string> UGUINames { 
			get {
				return _uGUINames;
			} 
		}

		public List<string> UGUIBundlePathes { 
			get {
				return _uGUIBundlePathes;
			} 
		}

		[HideInInspector]
		[SerializeField]
		private List<string> _baseCanvasList = new List<string>();
		[HideInInspector]
		[SerializeField]
		private List<string> _uGUINames = new List<string>();
		[HideInInspector]
		[SerializeField]
		private List<string> _uGUIBundlePathes = new List<string>();

        #endregion

        #region 接口

		public void RefreshBundleDictByData() {

			UIName2BundleDict.Clear();

			if(_uGUINames == null) {

                Debug.LogError("UGUIBaseData RefreshBundleDictByData error: UGUIName list is null.");

				return;
            }

			if(_uGUIBundlePathes == null) {

				Debug.LogError("UGUIBaseData RefreshBundleDictByData error: UGUIBundlePath list is null.");

				return;
			}

			int nameLen = _uGUINames.Count;
			int bundleLen = _uGUIBundlePathes.Count;

			if (nameLen != bundleLen) {

				Debug.LogError("UGUIBaseData RefreshBundleDictByData error: UGUIName length is not equal to UGUIBundlePath length.");

				return;
			}

			for (int i=0; i< nameLen; ++i) {
				UIName2BundleDict.Add(_uGUINames[i], _uGUIBundlePathes[i]);
			}
		}

        #endregion
    }
}
